package pro.cherish.mqstream.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.integration.support.MessageBuilder;
import pro.cherish.mqstream.producer.UsersSource;

/**
 * @author 创建人：lys
 * @version 版本号：V1.0
 * <p>
 * ***************************修订记录************************************
 * 2020-6-17 lys 创建该类功能。
 * **********************************************************************
 * </p>
 * @ClassName 类名：UserProducer
 * @Description 功能说明：
 * <p>
 * TODO
 * </p>
 * **********************************************************************
 * @date 创建日期： 2020-6-17 
 */

/**
 * 消息发送
 */
@EnableBinding(UsersSource.class)
public class UserProducer {

	@Autowired
	private UsersSource source;

	public void sendMessage(String msg) {
		try {
			source.output().send(MessageBuilder.withPayload(msg).build());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}